var Define = require("../../lib/Define.js")

Page({
  data: {
      list:[],
      isLoading:true
  },
  onReady:function(){
    this.requestList()
  },
  requestList:function(){
      var self = this

    wx.request({
      url: Define.value.baseUrl+"/activity/list?bid="+Define.value.bid,
      data: {},
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function(res){
        // success
        var data = res.data
        var results = []
        for(var index=0; index < data.data.length; index++){
            var item = data.data[index]
            item.startDateStr = Define.dateFrom(item.startDate,"yyyy-MM-dd")
            item.endDateStr = Define.dateFrom(item.endDate,"yyyy-MM-dd")
            results.push(item)
        }
        if(data.code == 200){
            self.setData({
                list:results,
                isLoading:false
            })
        }
      },
      fail: function(res) {
        // fail
      },
      complete: function(res) {
        // complete
      }
    })
  }
})